

#include <stdio.h>

#include <stdlib.h>

int check(int array[], int len, int key);
int main(int argc, const char * argv[]) {
    
    int arr[6] = {0};
    // for 循环产生6个随机数
    for (int i = 0; i < 6; ) {
        int num = arc4random_uniform(33) + 1;
        
        if (check(arr, 6, num) == 0) {
            arr[i] = num;
            i ++;
        }
    }
    
    for (int i = 0; i < 6; i ++) {
        printf("%d   ", arr[i]);
    }
    
    
    return 0;
}

// 检查数组中是否含有这个数
int check(int array[], int len, int key) {
    for (int i = 0; i < len; i ++) {
        if (key == array[i]) {
            printf("重复数%d\n", key);
            return 1;
            break;
        }
    }
    return 0;
}
